MD_MAX72xx LED Matrix Arduino Library: New Hardware Types

| MD_MAX72xx LED Matrix Arduino Library 2.10 Library to control connected MAX72XX devices as a pixel array

New Hardware Types

## A word on coordinate systems

Two Cartesian coordinate systems are used in the library

- one defines the pixels seen (display coordinates), and
- an underlying hardware coordinate system based on digits and segments mapping to the MAX72xx hardware control registers.

Display coordinates always have their origin in the top right corner of a display.

- Column numbers increase to the left (as do module numbers)
- Row numbers increase down (0..7)

All user functions are consistent and use display coordinates.

Display memory buffers are stored in hardware coordinates that depend on the hardware configuration (i.e. the module type). It is the job of the low level library functions to map display to hardware coordinates. Digit 0 is the lowest row/column number and Segment G is the lowest column/row number.

All the code to do this is in the is in the buffer and pixel modules. All other library modules are use the primitives made available in these modules.

## What needs to change?

As there is no standard way of wiring a LED matrix to the MAX72xx IC, each hardware type definition activates a series of coordinate mapping transformations. Possible changes are limited to combinations (8 in total) of

- swapping rows and column coordinates (digits and segments in MAX72xx),
- a reversal of row indices, and
- a reversal of column indices.

The hardware types defined in MD_MAX72xx.h activate different library code by defining appropriate values for the defines listed below, in the MD_MAX72xx_lib.h file.

- HW_DIG_ROWS - MAX72xx digits are mapped to rows in on the matrix. If digits are not rows then they are columns!
- HW_REV_COLS - Normal column coordinates orientation is 0 col on the right side of the display. Set to 1 to reverse this (0 on the left).
- HW_REV_ROWS - Normal row coordinates orientation is 0 row at top of the display. Set to 1 to reverse this (0 at the bottom).

## Determining the type of mapping

The library example code includes a utility called MD_MAX72xx_HW_Mapper. This is test software to map display hardware rows and columns. It uses a generic SPI interface and only one MAX72xx/8x8 LED module required. It is independent of the libraries as the code is used to directly map the display orientation by setting pixels on the display and printing to the serial monitor which MAX72xx hardware component (segment and digit) is being exercised.

By observing the LED display and the serial monitor you can build a map like the one below. It is worth noting the direction in which the rows and columns are scanned by the utility, as this is the easiest way to work out the row/column reversal values.

The result of these observations is a grid definition that looks somewhat like:

          DIG0 D1 D2 D3 D4 D5 D6 D7
    Seg G
    Seg F
    Seg E
    Seg D
    Seg C
    Seg B
    Seg A
    Seg DP

From this mapping it is clear

- MAX72xx digits map to the columns, HW_DIG_ROWS is 0.
- DIG0 is on the left (columns were also scanned left to right), so HW_REV_COLS should be set to 1 to reverse it to the standard 0 on the right.
- Seg G is at the top (rows were also top to bottom), so HW_REV_ROWS should be set to 0, as it is already standard with 0 on top.

Note that in some situations using the module 'upside down' will result in a better configuration than would otherwise be the case. An example of this is the generic module mapping. Also remember that the modules are daisy chained from right to left.

Having determined the values for the defines, the new mapping can be configured, or matched to an existing hardware type.